//
//  ScreenMoveView.m
//  宜居HD
//
//  Created by 张金国 on 16/4/28.
//  Copyright © 2016年 张金国. All rights reserved.
//

#import "ScreenMoveView.h"
#import "TitleView.h"
#import "BigButton.h"
#import "Masonry.h"
#import "UIColor+RandomColor.h"
#import "Macro.h"


@interface ScreenMoveView ()

@end

@implementation ScreenMoveView
#pragma mark - init
- (instancetype)init {
    if (self = [super init]) {
        [self setupConstraints];
    }
    return self;
}

#pragma mark - Private
- (void)setupConstraints {
    TitleView *titleView = [[TitleView alloc]initWithLineColor:[UIColor redColor] title:@"显示器移动控制" titleFont:kLabelTextColor];
    [self addSubview:titleView];
    [titleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(self).offset(10);
        make.height.equalTo(self.mas_height).multipliedBy(1/4.0f);
        make.width.equalTo(self.mas_width).multipliedBy(1/2.0f);
    }];
    BigButton *button1 = [[BigButton alloc] init];
    button1.backgroundColor = kSandboxieVcBkColor;
    button1.buttontype = BigButtonTypeNormal;
    button1.mark = 100;
    button1.heightPercent = 0.8; //图标和label占高度百分百
    button1.titleLabel.textColor = [UIColor randomColor];
    button1.image = [UIImage imageNamed:@"Left_arrows"];
    button1.title = @"默认状态";
    [button1 addTarget:self action:@selector(handleButtonEvent:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:button1];
    [button1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(titleView.mas_bottom);
        make.left.equalTo(self.mas_left).offset(SCREEN_WIDTH/4 - 200);
        make.width.height.equalTo(self.mas_height).multipliedBy(1.2/2.0f);
    }];
    BigButton *button2 = [[BigButton alloc] init];
    button2.mark = 101;
    button2.backgroundColor = kSandboxieVcBkColor;
    button2.buttontype = BigButtonTypeNormal;
    button2.heightPercent = 0.8; //图标和label占高度百分百
    button2.titleLabel.textColor = [UIColor randomColor];
    button2.image = [UIImage imageNamed:@"Right_arrows"];
    button2.title = @"默认状态";
    [button2 addTarget:self action:@selector(handleButtonEvent:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:button2];
    [button2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(titleView.mas_bottom);
        make.left.equalTo(button1.mas_right).offset(40);
        make.width.height.equalTo(self.mas_height).multipliedBy(1.2/2.0f);
    }];

}
#pragma mark - Event response
- (void)handleButtonEvent:(BigButton *)button {
    SelectType selectType = button.mark;
    
    if (self.delegate != nil && [self.delegate respondsToSelector:@selector(screenMoveViewSelectIndex:)]) {
        [self.delegate screenMoveViewSelectIndex:selectType];
    }
}


@end
